package com.example.qxfw.hbqx.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qxfw.common.entity.zy.AirpolConFcst;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

@Mapper
@DS("service")
public interface AirpolConFcstMapper extends BaseMapper<AirpolConFcst> {
    /**
     *根据观测时间段查询污染扩散等级预报
     * @param observtimeStart 观测时间起点
     * @param observtimeEnd 观测时间终点
     * @return
     */
    @Select("SELECT observtime, level, totalweight, asseaa, describe, condition " +
            "FROM airpol_con_fcst " +
            "WHERE observtime BETWEEN #{observtimeStart} AND #{observtimeEnd} ")
    List<AirpolConFcst> selectByObservTimeOfAirpolConFcst(Date observtimeStart, Date observtimeEnd);

    /**
     *根据观测时间更新污染扩散等级预报
     * @param observtime 观测时间
     * @param level 等级
     * @param totalweight 总权重
     * @param asseaa 评价
     * @param describe 描述
     * @param condition 条件
     * @return
     */
    @Update("UPDATE airpol_con_fcst " +
            "SET level = #{level}, totalweight = #{totalweight}, asseaa = #{asseaa}, describe = #{describe}, condition = #{condition} " +
            "WHERE observtime = #{observtime} ")
    int updateByObservTime(Date observtime, String level, Integer totalweight, String asseaa, String describe, String condition);

    /**
     *插入数据到污染扩散等级预报
     * @param observtime 观测时间
     * @param level 等级
     * @param totalweight 总权重
     * @param asseaa 评价
     * @param describe 描述
     * @param condition 条件
     * @return
     */
    @Insert("INSERT INTO " +
            "airpol_con_fcst (observtime, level, totalweight, asseaa, describe, condition) " +
            "VALUES " +
            "(#{observtime}, #{level}, #{totalweight}, #{asseaa}, #{describe}, #{condition} )")
    int insertOfAirPolConForecast(Date observtime, String level, Integer totalweight, String asseaa, String describe, String condition);








}
